#!/bin/bash

UNIT_TEST_MODE=0

function processArgs {
	# echo "hogehogeohogehogheogheo"
	while [[ ! -z "$1" ]]; do
		# echo "fufduafudfuasfuasf"
		# echo "dfsdfasfd     " $1
		case "$1" in
			--test)
			# echo "zmzmzmzmzmmzmzmzmzmzm"
			UNIT_TEST_MODE=1
			shift 1
			;;
		esac
	done
}
AGENT_DIR_BASE="."
AGENT_JAR_FILE="$AGENT_DIR_BASE/naito_rescue.jar"

KERNEL_DIR="/home/boss/rescue/rescue-competition2010"
KERNEL_BOOT_DIR=$KERNEL_DIR"/boot"
KERNEL_BOOT_SCRIPT=$KERNEL_BOOT_DIR"/start.sh"
KERNEL_BOOT_ARGS=" -m $KERNEL_DIR/maps/gml/test"

KERNEL_ADDRESS="localhost"
KERNEL_PORT=7000

CLASSPATH=`find ./jars -name "*.jar" | xargs | sed -e "s/ /:/g"`
CLASSPATH=$CLASSPATH:$AGENT_JAR_FILE

processArgs $*

echo "UNIT_TEST_MODE = " $UNIT_TEST_MODE
echo "KERNEL_BOOT_SCRIPT = " $KERNEL_BOOT_SCRIPT

#if [ $UNIT_TEST_MODE -eq 1 ] ; then
#	$KERNEL_BOOT_SCRIPT $KERNEL_BOOT_ARGS
#	sleep 5
#	java -Xmx256m -cp $CLASSPATH rescuecore2.LaunchComponents naito_rescue.viewer.NAITOViewer -h $KERNEL_ADDRESS -p $KERNEL_PORT --viewer.maximise=true --loadabletypes.inspect.dir=./jars &
#else
#	java -Xmx256m -cp $CLASSPATH rescuecore2.LaunchComponents naito_rescue.viewer.NAITOViewer -h $KERNEL_ADDRESS -p $KERNEL_PORT --viewer.maximise=true --loadabletypes.inspect.dir=./jars &
#fi
java -Xmx256m -cp $CLASSPATH rescuecore2.LaunchComponents naito_rescue.viewer.NAITOViewer -h $KERNEL_ADDRESS -p $KERNEL_PORT --viewer.maximise=true --loadabletypes.inspect.dir=./jars &
